<%--
  Created by IntelliJ IDEA.
  User: 陈俊雄
  Date: 2018/5/9
  Time: 11:47
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<div class="modal-header">
    <button class="close" ng-click="cancel()">
        <span aria-hidden="true">×</span>
    </button>
    <h3 class="modal-title" id="modal-title">{{ type == 0 ? '添加收单账户' : '修改收单账户'}}</h3>
</div>
<div class="modal-body" id="modal-body">
    <form name="myForm" class="form-horizontal">
        <uib-tabset active="activeForm">
            <uib-tab index="0" classes="m-b">
                <uib-tab-heading><i class="fa fa-user"></i>&nbsp;基本信息</uib-tab-heading>
                <%--{{myForm.$error}}--%>
                <div class="form-group m-t">
                    <label class="col-sm-2 control-label p-w-xs"><span class="text-danger">*</span>名称：</label>
                    <div class="col-sm-10">
                        <input class="form-control b-r-sm" name="accountName" type="text" placeholder="必填"
                               ng-model="acquirerAccountInfo.name" ng-blur="nameBlur($event, acquirerAccountInfo.name)"
                               required>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label p-w-xs"><span class="text-danger">*</span>收单机构：</label>
                    <div class="col-sm-10">
                        <select class="form-control b-r-sm" name="acquirerId" ng-model="acquirerAccountInfo.acquirerId"
                                ng-blur="acquirerBlur($event, acquirerAccountInfo.acquirerId)" required
                                ng-options="+(x.id) as x.name for x in acquirer">
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label p-w-xs"><span class="text-danger">*</span>通道交易币种类型：</label>
                    <div class="col-sm-10">
                        <select class="form-control b-r-sm" name="currencyType"
                                ng-model="acquirerAccountInfo.currencyType"
                                ng-blur="currencyTypeBlur($event, acquirerAccountInfo.currencyType)"
                                ng-options="x.firstValue as x.name for x in currencyType" required>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label p-w-xs"><span class="text-danger">*</span>结算币种：</label>
                    <div class="col-sm-10 clearfix">
                        <div class="col-sm-4 p-w-xs" ng-repeat="x in currency">
                            <div class="checkbox no-margins">
                                <input id="{{x.firstValue}}" name="currency" type="checkbox"
                                       ng-model="acquirerAccountInfo.currency[x.firstValue]"
                                       ng-checked="exists(x.firstValue, acquirerAccountInfo.currency)"
                                       ng-click="toggle(x.firstValue, acquirerAccountInfo.currency)"
                                       ng-required="!someSelected(acquirerAccountInfo.currency)">
                                <label for="{{x.firstValue}}" class="no-padding">{{x.name}}</label>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label p-w-xs"><span class="text-danger">*</span>状态：</label>
                    <div class="col-sm-10">
                        <select class="form-control b-r-sm" name="status" ng-model="acquirerAccountInfo.status"
                                ng-blur="statusBlur($event, acquirerAccountInfo.status)" required
                                ng-options="+(x.firstValue) as x.name for x in accountStatus">
                        </select>
                    </div>
                </div>
            </uib-tab>
            <uib-tab index="1" disable="nextDisabled(myForm, 0)">
                <uib-tab-heading><i class="fa fa-address-card"></i>&nbsp;通道配置</uib-tab-heading>
                <div class="form-group m-t">
                    <label class="col-sm-2 control-label p-w-xs">单笔限额：</label>
                    <div class="col-sm-10">
                        <input class="form-control b-r-sm" type="number" ng-model="acquirerAccountInfo.singleQuota">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label p-w-xs">日限额：</label>
                    <div class="col-sm-10">
                        <input class="form-control b-r-sm" type="number" ng-model="acquirerAccountInfo.dayQuota">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label p-w-xs">月限额：</label>
                    <div class="col-sm-10">
                        <input class="form-control b-r-sm" type="number" ng-model="acquirerAccountInfo.monthQuota">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label p-w-xs"><span class="text-danger">*</span>银行账户：</label>
                    <div class="col-sm-10">
                        <input class="form-control b-r-sm" name="account" type="text"
                               oninput="inputRegex(this, /\D/g)" placeholder="必填" ng-model="acquirerAccountInfo.account"
                               ng-blur="accountBlur($event, acquirerAccountInfo.account)" required>
                        <span class="help-block" ng-show="accountMessage != null">{{accountMessage}}</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label p-w-xs">银行参数：</label>
                    <div class="col-sm-10">
                    <textarea class="form-control b-r-sm" ng-model="acquirerAccountInfo.params"
                              style="resize: none;height: 100px"></textarea>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label p-w-xs">备注：</label>
                    <div class="col-sm-10">
                    <textarea class="form-control b-r-sm" ng-model="acquirerAccountInfo.remark"
                              style="resize: none;height: 100px"></textarea>
                    </div>
                </div>
            </uib-tab>
            <uib-tab index="2" disable="nextDisabled(myForm, 1)">
                <uib-tab-heading><i class="fa fa-users"></i>&nbsp;二抛设置</uib-tab-heading>
                <div class="form-group m-t">
                    <label class="col-sm-2 control-label p-w-xs"><span class="text-danger">*</span>二抛状态：</label>
                    <div class="col-sm-10">
                        <select class="form-control b-r-sm" ng-model="acquirerAccountInfo.isSecondAcquirerStatus"
                                ng-options="x.firstValue as x.name for x in accountStatus" required>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label p-w-xs"><span class="text-danger">*</span>二抛机构：</label>
                    <div class="col-sm-10">
                        <select class="form-control b-r-sm" ng-model="acquirerAccountInfo.secondAcquirerId"
                                ng-blur="secondAcquirerIdBlur($event, acquirerAccountInfo.secondAcquirerId)"
                                ng-options="+(x.id) as x.name for x in acquirer"
                                ng-disabled="acquirerAccountInfo.isSecondAcquirerStatus != 1">
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label p-w-xs"><span class="text-danger">*</span>二抛账户：</label>
                    <div class="col-sm-10">
                        <select class="form-control b-r-sm" ng-model="acquirerAccountInfo.secondAccountId"
                                ng-blur="secondAccountIdBlur($event, acquirerAccountInfo.secondAccountId)"
                                ng-options="+(x.id) as x.name for x in acquirerAccounts"
                                ng-disabled="acquirerAccountInfo.secondAcquirerId == null || acquirerAccountInfo.isSecondAcquirerStatus != 1">
                        </select>
                    </div>
                </div>
            </uib-tab>
        </uib-tabset>
    </form>
    <div class="row">
        <div class="col-sm-12">
            <div class="center">
                <button class="btn btn-sm" type="button" ng-click="confirm(acquirerAccountInfo, activeForm)"
                        ng-class="{'btn-primary': activeForm != 2, 'btn-success': activeForm == 2}"
                        ng-disabled="nextDisabled(myForm, activeForm)">
                    {{activeForm != 2 ? '下一步' : '确定'}}
                </button>
            </div>
        </div>
    </div>
</div>
